# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html


from pymongo import MongoClient
class MeituanchengduPipeline(object):
    def __init__(self):
        self.mg = MongoClient()
        self.db = self.mg.meituan
    def process_item(self, item, spider):
        diqu = item['diqu']
        jiedao = item['jiedao']
        dianming = item['dianming']
        tuijiancai = item['tuijiancai']
        chengshi = 'chengdu'
        collection = self.db[chengshi]
        dianming = dianming.replace('.','')

        document ={
            'chengshi':chengshi,
            'diqu':diqu,
            'jiedao':jiedao,
            'dianming':dianming,
            'tuijiancai':tuijiancai,
        }
        collection.save(document)
        # print(document)





